from transitions.extensions import GraphMachine


class Matter:
    pass


states = ['固态 solid', '液态 liquid', '气态 gas', '等离子态 plasma']
transitions = [
    {'trigger': '熔化 melt', 'source': '固态 solid', 'dest': '液态 liquid'},
    {'trigger': '蒸发 evaporate', 'source': '液态 liquid', 'dest': '气态 gas'},
    {'trigger': '升华 sublimate', 'source': '固态 solid', 'dest': '气态 gas'},
    {'trigger': '电离 ionize', 'source': '气态 gas', 'dest': '等离子态 plasma'}
]
machine = GraphMachine(Matter(), states=states, transitions=transitions, initial='固态 solid')
# machine = GraphMachine(lump, states=states, transitions=transitions, initial='solid', show_auto_transitions=True)  # 完整流程
graph = machine.get_graph()
graph.edge_attr['fontname'] = 'Microsoft Yahei'
graph.node_attr['fontname'] = 'Microsoft Yahei'
graph.graph_attr['fontname'] = 'Microsoft Yahei'
graph.graph_attr['dpi'] = '600'  # 设置分辨率
# graph.graph_attr.pop('label')  # 删除标题
graph.draw('result.png', prog='dot')
